var e = getApp();

Page({
    data: {
        rid: "",
        redpack_info: {},
        receive_amount: "",
        receive_records: [],
        page: 1,
        finished: !1
    },
    onLoad: function(e) {
        var a = e.rid;
        a && this.setData({
            rid: a
        });
    },
    onShow: function() {
        this.getData();
    },
    getData: function() {
        var a = this, t = e.getNetAddresss("plugin.redpack-user.frontend.receiveLogDetail.index");
        e._getNetWork({
            url: t,
            data: {
                rid: this.data.rid
            },
            success: function(e) {
                if (1 === e.data.result) {
                    var t = e.data.data, i = !1, r = t.receive_logs;
                    (a.data.page >= r.last_page || r.data.length < r.per_page) && (i = !0), a.setData({
                        finished: i,
                        page: ++a.data.page,
                        receive_amount: t.receive_amount,
                        redpack_info: t.redpack_info,
                        receive_records: r.data
                    });
                } else wx.showToast({
                    title: e.data.msg
                });
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (!this.data.finished) {
            var t = e.getNetAddresss("plugin.redpack-user.frontend.receiveLogDetail.index");
            e._getNetWork({
                url: t,
                data: {
                    rid: this.data.rid,
                    page: this.data.page
                },
                success: function(e) {
                    if (1 === e.data.result) {
                        var t = !1, i = e.data.data.receive_logs, r = a.data.receive_records.concat(i.data);
                        (a.data.page >= i.last_page || i.data.length < i.per_page) && (t = !0), a.setData({
                            finished: t,
                            page: ++a.data.page,
                            receive_records: r
                        });
                    } else wx.showToast({
                        title: e.data.msg
                    });
                }
            });
        }
    },
    onReachBottom: function() {
        this.getMoreData();
    }
});